home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 May: Tool Chest / Dev.CD May 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / SPEC Libs / Misc.Lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  5.9 KB  |  165 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        Misc.Lib
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    KTA, KL, ML, GS et al
  9. #
  10. #    Copyright:    © 1993-1996 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #    <1.0.16>      2/8/96    JC        Changed all window .r (Rect) traits to .b (bound) traits and
  19. #                                    changed any window insets to reflect new bound rect.
  20. #    <1.0.15>     2/28/95    ML        marked
  21. #    1.0.14+>     2/28/95    ML        marked
  22. #    <1.0.14>     2/14/95    KTA        AboutBox() - Added BooleanFlag to FindWindow() call
  23. #    <1.0.13>     9/20/94    ML        AboutBox() - add escape key
  24. #    1.0.12+>     9/20/94    ML        AboutBox() - add escape key
  25. #    <1.0.12>     3/29/94    KTA        AboutBox() - Click in the center of window instead of screen as
  26. #                                    default.
  27. #    <1.0.11>    12/13/93    KTA        Changed name of CenterOfScreenClick() to CenterOfRectClick() and
  28. #                                    added support for different types of rects.
  29. #    <1.0.10>     12/2/93    KTA        Updated output
  30. #     <1.0.9>     12/2/93    KTA        Deleted the task DoSpecialTest() it was replaced with hooks.
  31. #                                    Fixed problem where AboutBox() was not reporting any problems if
  32. #                                    window did not appear.
  33. #    <1.0.7+>    11/19/93    NAGA        modify TCS format
  34. #     <1.0.7>     8/25/93    KTA        Added support for parity checking the TCS stack.
  35. #     <1.0.6>     7/19/93    KTA        Updates for FindWindow() to handle descriptors.
  36. #     <1.0.5>     7/14/93    KTA        International Support: See AboutBox().
  37. #        <1+>     5/21/93    NAGA        Adding header and porting old files to follow new standards
  38. #
  39. # ****************************************************************************
  40. #
  41.  
  42. ########################################################################
  43. #                            External libraries 
  44. #=======================================================================
  45. Libraries "OutPut.Lib","LaunchQuit.Lib","TCS.Lib","UserInterface.Lib", "Geometry.Lib";
  46.  
  47.  
  48. #########################################################################
  49. #                         CenterofRectClick(pSpecifier)
  50. #=======================================================================
  51. # Author:          KTA
  52. # Description:    Clicks in the center of the input parameter <pSpecifier>
  53. # Parameters:    pSpecifier
  54. #                        -1 - indicates the screen
  55. #                        integer <> -1 (or string) is a window specifier
  56. #                        list - should be valid rectangle
  57. # Returns:        Nada
  58. #=======================================================================
  59. # History:
  60. # KTA    12/13/93    Changed the name from CenterofScreenClick and added ability 
  61. #                    to specifiy different types of Rects
  62. # JC     2/6/96     Changed theWind.r to theWind.b.
  63. #########################################################################
  64. TASK CenterofRectClick(pSpecifier := -1) 
  65. begin
  66.     parameterType := TypeOf(pSpecifier);
  67.     if(parameterType = 'integer') or (parameterType = 'string')
  68.     begin
  69.         if(pSpecifier = -1)
  70.         begin
  71.             Match[screen r:?ScreenRect m:true];
  72.             myPoint := CenterPointOfRect(ScreenRect);
  73.             theDescriptor := 'the screen';
  74.         end;
  75.         else
  76.         begin
  77.             theWind := findWindow(pSpecifier);
  78.             theWindowRect := theWind.b;
  79.             theWindowTitle := theWind.t;
  80.             myPoint := CenterPointOfRect(theWindowRect);
  81.             theDescriptor := "the window titled '{theWindowTitle}'";
  82.         end;
  83.     end;
  84.     if(parameterType = 'list') and (Card(pSpecifier) = 4)
  85.     begin
  86.         myPoint := CenterPointOfRect(pSpecifier);
  87.         theDescriptor := "the rect ({pSpecifier})";
  88.     end;
  89.     
  90.  
  91.     move a:myPoint;
  92.     click;
  93.     LogStr("Moved to the center of {theDescriptor} and clicked");
  94. end; # CenterofRectClick()
  95.  
  96.  
  97. #########################################################################
  98. #                 AboutBox(pDismissAboutBox)
  99. #=======================================================================
  100. # Author:          ML
  101. # Description:    Test the About Box
  102. # Parameters:    pDismissAboutBox -    -1    Escape key
  103. #                                    0    Return key
  104. #                                integer > 0    Click in center of screen {integer} times
  105. #                                {string} select button named {string}
  106. # Returns:        0 - Something failed
  107. #                1 - Successfully selected and dismissed the about box.
  108. #=======================================================================
  109. # History:
  110. # KTA    7/8/93    Changed check for About… menuItem to selectMenuItem(1,1); - intl
  111. # KTA    7/19/93    Changed descriptor so it is not embedded in a list.
  112. # KTA    8/24/93    TCS stack parity check
  113. # KTA    12/01/93    Check to make sure window appears (bug 1121683)
  114. # KTA    3/29/94        Click in the center of window instead of screen
  115. # ML    9/20/94    Add support for Escape key
  116. # KTA    2/14/95    Added BooleanFlag to FindWindow() call
  117. ########################################################################
  118. TASK AboutBox(pDismissAboutBox := 0) 
  119. begin
  120.     tcReturnVal := 0;
  121.     failStr := '';
  122.     #match[menuItem t:?AboutItem o:1 m:[menu o:1]]!;
  123.     theFrontWindow := match[window o:1]!;
  124.     TCSStart({ 1, global kTCSetAboutBox },"Select 'About...'");
  125.     
  126.     returnVal := SelectMenuItem(1,1);
  127.     wait(2);
  128.     AboutBoxWindow:= match[window o:1]!;
  129.     if (theFrontWindow = AboutBoxWindow)
  130.     begin
  131.         tcReturnVal := 0;
  132.         failStr := "!@#$% The 'About Box' did not appear";
  133.         LogStr(failStr);
  134.     end;
  135.     else if (returnVal)
  136.         tcReturnVal := 1;
  137.     
  138.     TCSEnd({ 1, global kTCSetAboutBox },tcReturnVal, failStr);                # Select the 'About…' window
  139.     
  140.     if(tcReturnVal)
  141.     begin
  142.         TCSStart({ 2, global kTCSetAboutBox },"Dismiss About Box");
  143.         if pDismissAboutBox = 0
  144.             SpecialKey(returnKey , "Return Key");
  145.         else if (TypeOf(pDismissAboutBox) = 'string')
  146.             selectButton(pDismissAboutBox);            
  147.         else if (TypeOf(pDismissAboutBox) = 'integer')
  148.         begin
  149.             if (pDismissAboutBox = -1)
  150.                 SpecialKey(EscapeKey , "Escape Key");
  151.             else if (pDismissAboutBox > 0)
  152.                 for x:= 1 to pDismissAboutBox    
  153.                     CenterofRectClick(1);
  154.         end; # if (TypeOf(pDismissAboutBox) = 'integer')
  155.         
  156.         if not FindWindow(AboutBoxWindow, true)
  157.             tcReturnVal := 1;
  158.         else
  159.             tcReturnVal := 0;
  160.             
  161.         TCSEnd({ 2, global kTCSetAboutBox },tcReturnVal);
  162.     end;
  163.     return(tcReturnVal);
  164. end;
  165.